// Copyright 2010 The Go Example Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import (
	"fmt"
	"os"
)

func main() {

	fileName := "data/hello.txt"
	//Create data dir
	os.Mkdir("data", 0444)
	//Create file
	file, err := os.Open(fileName, os.O_CREATE, 0)
	if file == nil {
		fmt.Printf("can't create file; err=%s\n", err.String())
		os.Exit(1)
	}
	hello := "Hello World!\n"
	//Write string type data  
	file.WriteString("你好！\n")

	//Write []byte type data  
	file.Write([]byte(hello))

	file.Close()
}
